const Crawler = require("crawler");

let jsdom = require("jsdom");
const cra = new Crawler({
  maxConnections: 10,
  forceUTF8: true
  // jQuery: jsdom
});

export function c(uri: String, fn: Function, ...args): void {
  cra.queue([
    {
      uri: uri,
      jQuery: true,

      // The global callback won't be called
      callback: function(error, res, done) {
        if (error) {
          console.log(error);
        } else {
          fn(res, res.$);
        }
        done();
      }
    }
  ]);
}

/**
 * c.queue(
     "http://api.smq1.com/?url=http://player.youku.com/embed/XNDE5ODg3Mzg1Ng"
 );
 *
 * 连接地址 /   "https://v.youku.com/v_show/id_XNDE5ODg3Mzg1Ng==.html?spm=a2h0k.11417342.soresults.dtitle&s=247d76efbfbdefbfbd0e"
 * 真是地址 http://player.youku.com/embed/XNDE5ODg3Mzg1Ng
 *
 *  {
 *  uri1 : http://api.smq1.com/?url=, //紫云智能视频解析 1
 *  https://jx.km58.top/jx/?url= //怀疑同意解析地址被封装;5
 *  http://17kyun.com/api.php?url= // 2
 * https://jx.hezeshi.net/ce/jlexi.php?url= 3 //怀疑所有解析地址用同一个解析api
 *
 * }
 *
 * 完整地址解析方案
 * {
 * urli : http://api.51ckm.com/Box.php?url= //box 解析
 * }
 */
